import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Main {
    //用户登陆，此处使用向上转型来接受返回值
    public static User login(){
        Scanner in = new Scanner(System.in);
        System.out.println("请输入你的名字");
        String name = in.nextLine();
        System.out.println("hello " + name + " 欢迎来到图书管理系统");
        System.out.println("请输入你的身份");
        System.out.println("1---管理员      2---普通用户");
        int user = in.nextInt();
        if (user == 1){
            return new AdminUser(name);
        } else if (user ==2) {
            return new NormalUser(name);
        } else {
            return null;
        }
    }

    //用户操作
    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();
        while (true){
            //调用用户对应的菜单
            int choice = user.menu();
            user.doOperation(choice,bookList);    //获得choice后传递给数组，对booklist进行操作
        }
    }
}